########################
# These are for gcc
# See
# o GCC homepage
#   http://www.gnu.org/software/gcc
# o GCC compilations flags
#   http://www.gnu.org/software/gcc/onlinedocs/gcc_2.html
# o GCC for Win32
#   http://sourceware.cygnus.com
#   ftp://sunsite.org.uk/Mirrors/sourceware.cygnus.com/pub/cygwin/
########################

ifeq ($(SMALLCODE), 1)
C_OPT = -Os 
else
C_OPT = -O3 
endif

CDEFINES = \
 -DCINTERFACE \
 -DNONAMELESSUNION \
 -DWIN32 \
 -D_WIN32 \
 -U_NO_COM

CWARNINGS = \
    -ansi \
    -pedantic \
    -Werror \
    -Wall \
    -W \
    -Wcast-align \
    -Wcast-qual \
    -Wchar-subscripts \
    -Wcomment \
    -Wformat \
    -Wimplicit \
    -Wimplicit-function-declaration \
    -Wimplicit-int \
    -Winline \
    -Wlong-long \
    -Wmain \
    -Wmissing-declarations \
    -Wmissing-noreturn \
    -Wmissing-prototypes \
    -Wmultichar \
    -Wnested-externs \
    -Wparentheses \
    -Wpointer-arith \
    -Wreturn-type \
    -Wsign-compare \
    -Wstrict-prototypes \
    -Wswitch \
    -Wtrigraphs \
    -Wundef \
    -Wuninitialized \
    -Wunknown-pragmas \
    -Wunused \
    -Wwrite-strings 

#    -Wid-clash-32 \
#    -Waggregate-return \
#    -Wredundant-decls \
#    -Wbad-function-cast
#    -Wconversion
#    -Wlarger-than-len 
#    -Wtraditional
#    -Wshadow 

ifeq ($(COPTIMIZE), 1)
CFLAGS += $(CWARNINGS) $(C_OPT) $(CDEFINES) -DNDEBUG -U_DEBUG
else
# CFLAGS += -Wall -O0
# gcc requires the generation of a dependency tree, 
# and hence at least -O1,
# to detect any use of uninitialized variables
CFLAGS +=  $(CWARNINGS) -O1 $(CDEFINES) -UNDEBUG -D_DEBUG
endif

ifeq ($(CDEBUG), 1)
CFLAGS += -g
endif

# These seem to be platform specific, not compiler specific

ifeq ($(NOASM), 1)
CFLAGS += -DNOASM 
endif


ifeq ("$(CPU)", "")
CPU=pentiumpro
endif

CFLAGS += -c -mcpu=$(CPU) \
	-DVC_EXTRALEAN  -DWIN32_EXTRA_LEAN -DWIN32_LEAN_AND_MEAN \
	-DHMONITOR_DECLARED -D_LPCWAVEFORMATEX_DEFINED -D_WIN32_WCE

CFLAGS += -fno-rtti -fno-exceptions

ifeq ("$(COMPILER)", "")
COMPILER=cc
endif

ifeq ("$(LINKER)", "")
# It should be this, but we have a rather strange idea of LINKER
LINKER=gcc
endif

ifeq ("$(DXSDK)", "")
DXSDK='d:/mssdk'
endif

CC        = gcc
CPP       = $(CC)
COUT      = -c -o 
SOUT      = -S -o $@
CPPOPT    = -E -P

LD        = gcc
LOUT      = -o 
LFLAGS = \
-ldxguid \
-lddraw \
-ldinput \
-lkernel32 \
-luser32 \
-lgdi32 \
-lshell32 \
-lwinmm \
-lm \
-lcrtdll 

AS        = ml
ASFLAGS   = -I$(SRCDIR) -I$(DEVDIR)/$(RWTARGET) -c -W2 -Cp -Zm -DFUNCSTD -DBCC -DSTACK -coff
AOUT      = -nologo -Fo

# Librarian options (for append, we include the source lib again)
AR		= ar -r
ARCREATEFLAGS   = $@ $^
ARAPPENDFLAGS	= -out:$@ $@

# How to run programs (no need for shell/simulator)
RUNIT		=

# We do want assembler
NOASM = 1

# Directory creation
ifndef MD
MD = mkdir -p
endif

# Patch support
ifeq ($(RWPATCH), 1)
RWLIBS +=					\
	$(RWLIBDIR)/$(LP)rppatch.$(L)			\
	$(RWLIBDIR)/$(LP)rtbezpat.$(L)
endif # ($(RWPATCH), 1)

CPPFLAGS += $(CFLAGS)

